/**
 * 路由配置文件
 */
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

// 后台管理子组件
import Layout from '../views/layout/Layout'

export const constantRouterMap = [
  {path: '/login', component: () => import('@/views/manage/login'), hidden: true},
  {path: '/404', component: () => import('@/views/layout/404'), hidden: true},
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/template/dashboard/index')
    }]
  }
]

export default new Router({
  mode: 'history',
  isAddDynamicMenuRoutes: false,
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})

/**
 * 权限控制数组
 * super：全有
 * common：有标注的才有
 */
export const asyncRouterMap = [
  {
    path: '/manage',
    component: Layout,
    alwaysShow: true,
    name: 'manage',
    redirect: '/dashboard',
    meta: {title: '平台管理', icon: 'example'},
    children: [
      {
        path: 'empManage',
        component: () => import('@/views/manage/SxEmpManage'),
        name: 'empManage',
        meta: {title: '管理员管理', roles: ['super']}
      },
      {
        path: 'SxMenuConfigManage',
        component: () => import('@/views/manage/SxMenuConfigManage'),
        name: 'SxMenuConfigManage',
        meta: {title: '菜单管理', roles: ['super']}
      },
      {
        path: 'indexCategoryManage',
        component: () => import('@/views/manage/SxIndexCategoryManage'),
        name: 'indexCategoryManage',
        meta: {title: '首页类别', roles: ['super']}
      },
      {
        path: 'shopManage',
        component: () => import('@/views/manage/shopManage'),
        name: 'shopManage',
        meta: {title: '门店管理', roles: ['super']}
      },
      {
        path: 'productManage',
        component: () => import('@/views/manage/SxProductBasicInfoManage'),
        name: 'productManage',
        meta: {title: '商品管理', roles: ['super']}
      },
      {
        path: 'itemConfig',
        component: () => import('@/views/manage/SxProductItemConfigManage'),
        name: 'itemConfigManage',
        meta: {title: '销售属性值配置管理', noCache: true, roles: ['super']},
        hidden: true
      },
      {
        path: 'itemManage/:pid',
        component: () => import('@/views/manage/SxProductItemManage'),
        name: 'itemManage',
        meta: {title: '销售属性管理', noCache: true, roles: ['super']},
        hidden: true
      },
      {
        path: 'orderImage',
        component: () => import('@/views/manage/SxOrderImgManage'),
        name: 'orderImage',
        meta: {title: '订单图片详情', noCache: true, roles: ['super', 'shop', 'common']},
        hidden: true
      },
      {
        path: 'https://mp.weixin.qq.com/',
        meta: { title: '微信平台', roles: ['super'] }
      },
      {
        path: 'SxRoleManage',
        component: () => import('@/views/manage/SxRoleManage'),
        name: 'SxRoleManage',
        meta: {title: '角色权限', noCache: true, roles: ['super', 'shop', 'common']},
      }]
  },
  {
    path: '/shopManage',
    component: Layout,
    alwaysShow: true,
    name: 'manage',
    redirect: '/dashboard',
    meta: {title: '门店管理', icon: 'example' ,roles: ['super', 'shop', 'common']},
    children: [
      {
        path: 'scheduleManage',
        component: () => import('@/views/manage/SxScheduleInfoManage'),
        name: 'scheduleManage',
        meta: {title: '排单管理', noCache: true, roles: ['super', 'shop']}
      },
      {
        path: 'sxScheduleDetailManage',
        component: () => import('@/views/manage/SxScheduleDetailManage'),
        name: 'sxScheduleDetailManage',
        meta: {title: '排单表查询', noCache: true, roles: ['super', 'shop']}
      },
      {
        path: 'orderManage',
        component: () => import('@/views/manage/SxOrderRecordManage'),
        name: 'orderManage',
        meta: {title: '线上订单管理', roles: ['super', 'shop', 'common']}
      },
      {
        path: 'xxOrderManage',
        component: () => import('@/views/manage/SxXxOrderRecordManage'),
        name: 'xxOrderManage',
        meta: {title: '线下订单管理', roles: ['super', 'shop', 'common']}
      },
      {
        path: 'SxEvaluateRecordManage',
        component: () => import('@/views/manage/SxEvaluateRecordManage'),
        name: 'SxEvaluateRecordManage',
        meta: {title: '订单评价', roles: ['super', 'shop', 'common']}
      },
      {
        path: 'echart',
        component: () => import('@/views/manage/echart'),
        name: 'echart',
        meta: {title: '订单报表', roles: ['super', 'shop', 'common']}
      }
    ]
  },
  {
    path: '/gifi',
    component: Layout,
    alwaysShow: true,
    name: 'manage',
    redirect: '/dashboard',
    meta: {title: '礼品管理', icon: 'example', roles: ['super']},
    children: [
      {
        path: 'cardTypeManage',
        component: () => import('@/views/manage/SxCardTypeDictManage'),
        name: 'cardTypeManage',
        meta: {title: '礼品卡类别', roles: ['super']}
      },
      {
        path: 'cardInfoManage',
        component: () => import('@/views/manage/SxCardInfoManage'),
        name: 'cardInfoManage',
        meta: {title: '礼品卡管理', roles: ['super']}
      },
      {
        path: 'userCardRecordManage1',
        component: () => import('@/views/manage/SxUserCardRecordManage1'),
        name: 'userCardRecordManage',
        meta: {title: '礼品卡记录', roles: ['super']}
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    alwaysShow: true,
    name: 'manage',
    redirect: '/dashboard',
    meta: {title: '用户管理', icon: 'example', roles: ['super']},
    children: [
      {
        path: 'SxUserInfoManage',
        component: () => import('@/views/manage/SxUserInfoManage'),
        name: 'SxUserInfoManage',
        meta: {title: '用户管理', roles: ['super']}
      },
      {
        path: 'SxUserRankManage',
        component: () => import('@/views/manage/SxUserRankManage'),
        name: 'SxUserRankManage',
        meta: {title: '等级管理', roles: ['super']}
      }
    ]
  },
  {
    path: '/marketing',
    component: Layout,
    alwaysShow: true,
    name: 'manage',
    redirect: '/dashboard',
    meta: {title: '营销管理', icon: 'example', roles: ['super']},
    children: [
      {
        path: 'SxConfigManage',
        component: () => import('@/views/manage/SxConfigManage'),
        name: 'SxConfigManage',
        meta: {title: '配置管理', roles: ['super']}
      },
      {
        path: 'SxUserBonus',
        component: () => import('@/views/manage/SxUserBonus'),
        name: 'SxUserBonus',
        meta: {title: '个人红包', roles: ['super']}
      },
      {
        path: 'SxBatchUserBonus',
        component: () => import('@/views/manage/SxBatchUserBonus'),
        name: 'SxBatchUserBonus',
        meta: {title: '群发红包', roles: ['super']}
      },
      {
        path: 'SxBoundTypeManage',
        component: () => import('@/views/manage/SxBoundTypeManage'),
        name: 'SxBoundTypeManage',
        meta: {title: '系统红包', roles: ['super']}
      },
      {
        path: 'SxBonusRecordManage',
        component: () => import('@/views/manage/SxBonusRecordManage'),
        name: 'SxBonusRecordManage',
        meta: {title: '红包流水查询', roles: ['super']}
      },
      {
        path: 'SxBoundTypeManage',
        component: () => import('@/views/manage/SxBoundTypeManage'),
        name: 'SxBoundTypeManage',
        meta: {title: '分享有礼查询', roles: ['super']}
      },
      {
        path: 'SxBoundTypeManage',
        component: () => import('@/views/manage/SxBoundTypeManage'),
        name: 'SxBoundTypeManage',
        meta: {title: '至美传递查询', roles: ['super']}
      }
    ]
  },
  {
    path: '/other',
    component: Layout,
    alwaysShow: true,
    name: 'manage',
    redirect: '/dashboard',
    meta: {title: '其他', icon: 'example', roles: ['super']},
    children: [
      {
        path: 'companyManage',
        component: () => import('@/views/manage/SxCompanyManage'),
        name: 'companyManage',
        meta: {title: '企业登记外拍管理', roles: ['super']}
      },
      {
        path: 'problemInfoManage',
        component: () => import('@/views/manage/SxProblemInfoManage'),
        name: 'problemInfoManage',
        meta: {title: '常见问题维护', roles: ['super']}
      },
      {
        path: 'SxSuggestManage',
        component: () => import('@/views/manage/SxSuggestManage'),
        name: 'SxSuggestManage',
        meta: {title: '意见反馈', roles: ['super']}
      },

      {
        path: 'solveRecordManage',
        component: () => import('@/views/manage/SxUserSolveRecordManage'),
        name: 'solveRecordManage',
        meta: {title: '问题解决反馈', roles: ['super']}
      }
    ]
  },

  {path: '*', redirect: '/404', hidden: true}
]
